#!/bin/bash

PID=0

   echo "Killing JBoss server..."
   PID=`ps -ef | grep "jboss-as" | grep -v grep | awk '{print $2}'`

   if [[ ! -z $PID ]];
   then
        echo "Attempting to kill process $PID (JBoss)"
        kill $PID
        while [ 1 ];
        do
            if ps --pid $PID;
            then
                echo -n ".";
                sleep 1;
            else
                break;
            fi
        done
   else
        echo "Server was not running"

    fi

echo "Defined process done."
